<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>SSE</title>
</head>
<body>
    <div id="sse"></div>

    <script>
        // let eventSource = new EventSource('/sse/data');
        let eventSource = new EventSource('/sse/stream');
        eventSource.onmessage = function(event) {
            document.getElementById('sse').innerHTML = event.data;
        }

        eventSource.addEventListener('foo', function(event) {
            document.getElementById('sse').innerHTML = event.data;
        })

        eventSource.addEventListener('end', function(event) {
            eventSource.close();
        })
    </script>
</body>
</html>